//
// Created by 10334 on 2022/9/15.
//
#include "element.h"
#include "initialize_demo.h"
#include "initialize_demo_large.h"
#define INITIALIZE_DEMO_LARGE

Node::Node(int identifier, string *category, int hyper_period, int utilization, vector<int> *con_task) {
	this->identifier = identifier;
	this->category = category;
	this->hyper_period = hyper_period;
	this->utilization = utilization;
	this->con_task = con_task;
}

Link::Link(int identifier, int src_node, int des_node, int hyper_period, int utilization, vector<int> *con_message) {
	this->identifier = identifier;
	this->src_node = src_node;
	this->des_node = des_node;
	this->hyper_period = hyper_period;
	this->utilization = utilization;
	this->con_message = con_message;
}

Function::Function(int identifier, vector<int>*con_task, int rct_delay, int age_delay) {
	this->identifier = identifier;
	this->con_task = con_task;
	this->rct_delay = rct_delay;
	this->age_delay = age_delay;
}

Task::Task(int identifier, Node* res_node, int period, double length, string *state,
           int offset, int rct_instance, int age_instance) {
	this->identifier = identifier;
	this->res_node = res_node;
	this->period = period;
	this->length = length;
	this->state = state;
	this->offset = offset;
	this->rct_instance = rct_instance;
	this->age_instance = age_instance;
}

Message::Message(int identifier, int src_node,
                 int des_node, int period, int length,
                 double bandwidth, string *state, int inject, vector<int> *path, vector<int> *offset,
                 int communication_delay) {
	this->identifier = identifier;
	//this->src_task = src_task;
	this->src_node = src_node;
	//this->des_task = des_task;
	this->des_node = des_node;
	this->period = period;
	this->length = length;
	this->bandwidth = bandwidth;
	this->state = state;
	this->inject = inject;
	this->path = path;
	this->offset = offset;
	this->communication_delay = communication_delay;
}

Avionics::Avionics(string *net_case, int time_out, double accuracy) {
	this->net_case = net_case;
	this->time_out = time_out;
	this->accuracy = accuracy;
#if defined INITIALIZE_DEMO
	using namespace demo;
#elif defined INITIALIZE_DEMO_LARGE
	using namespace demo_large;
#endif
	all_node = initialize_all_node(net_case);
	all_link= initialize_all_link(net_case);
	all_function= initial_all_function(net_case);
	all_task= initialize_all_task(net_case,all_node);
	all_message= initialize_all_message(net_case,all_task);
	average_com_delay = -1;
	average_rct_delay = -1;
	average_age_delay = -1;
	schedulable_message_count = -1;
	schedulable_function_count = -1;
	running_duration = nullptr;
	optimization_log = nullptr;
}
